package com.homework2.demo1;

import com.homework.demo1.MustStringArgumentException;

public class Student {
    private String name;


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Student() {
    }

    public Student(String name) {
        this.name = name;
    }

    public String printName(Object greeting){
        if(!(greeting instanceof String)){
            throw new MustStringArgumentException("传参必须为String类型");
        }
        String str = this.getName() + "," + greeting;
        return str;
    }

    public static void main(String[] args) {
        Student student = new Student("张三");
        try {
            String s = student.printName("欢迎你");
            System.out.println(s);
            String s2 = student.printName(111);
            System.out.println(2);
        }catch (MustStringArgumentException mse){
            System.out.println("异常信息："+mse.getMessage());
        }

    }
}
